local base = piece "base"
local pannel1 = piece "pannel1"
local pannel2 = piece "pannel2"

local function OpenPannel(piece, sideturn)
        Turn(piece, z_axis, sideturn*-0.8, 0.5)
        WaitForTurn(piece, z_axis)    
        Turn(piece, z_axis, sideturn*-0.88, 0.3)
        WaitForTurn(piece, z_axis)   
        Turn(piece, z_axis, sideturn*-0.90, 0.2)
        WaitForTurn(piece, z_axis)
        Turn(piece, z_axis, sideturn*-0.92, 0.1)
end

local function Open()
        Signal(2)
        SetSignalMask(1)

	StartThread(OpenPannel, pannel1, 1)
	StartThread(OpenPannel, pannel2, -1)
        return true
end

local function Close()
        Signal(1)
        SetSignalMask(2)

	Turn(pannel1, z_axis, 0, 1)
	Turn(pannel2, z_axis, 0, 1)
        return true
end

function script.Activate ( )
        StartThread( Open )

end

function script.Deactivate ( )
        StartThread( Close )
end
